Skip to content

Conversation

@zombieJ
Copy link
Member

@zombieJ zombieJ commented Jan 29, 2026

Summary by CodeRabbit

发布说明

  • 重构
    • 优化了复选框组件的样式和DOM结构,改进了视觉表现和交互效果。
    • 简化了内部标记,减少了不必要的DOM节点,提升了性能。

✏️ Tip: You can customize this high-level summary in your review settings.

Co-Authored-By: Claude (GLM-4.7) <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @zombieJ, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the checkbox component by eliminating an unnecessary inner span element from its DOM structure. This change simplifies the component's HTML output and its associated Less/CSS styling, making the component leaner and potentially improving rendering performance. The styling logic has been consolidated, and test snapshots have been updated to align with the new, simplified structure.

Highlights

  • DOM Simplification: The redundant <span> element with the class -inner has been removed from the checkbox component's render output, streamlining the HTML structure.
  • CSS Refactoring: All styling rules previously targeting the .rc-checkbox-inner element have been migrated and consolidated directly onto the main .rc-checkbox class, simplifying the stylesheet.
  • Test Snapshot Updates: Existing test snapshots have been updated to reflect the removal of the inner <span> element, ensuring consistency with the new DOM structure.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

演练

此PR对复选框组件进行了结构和样式优化:简化了DOM层级结构,移除了内部装饰性跨度元素;同时重构了LESS样式表,将原嵌套的内部前缀类样式直接整合到主元素上,并优化了伪元素、悬停、禁用状态和动画的处理方式。

变更内容

含义类别 / 文件 变更摘要
样式重构
assets/index.less
全面重写复选框CSS样式:移除嵌套的-inner类选择器,使用&:after伪元素处理勾选标记;调整-input定位以覆盖完整元素;增强禁用状态、选中状态、悬停行为的样式定义;优化动画关键帧(amCheckboxIn/amCheckboxOut)的transform原点和opacity属性。
DOM简化
src/index.tsx
移除render方法中的内部装饰性span元素(${prefixCls}-inner),减少DOM节点层级。

估计审查工作量

🎯 3 (中等复杂) | ⏱️ ~20 分钟

可能关联的PR

诗篇

🐰 小小勾框焕新颜,
层级减一显简洁,
样式融合伪元素间,
去芜存菁动画全,
一行删除千般简。 ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰、具体地描述了主要变化:删除内部div元素以简化DOM结构,与提交的所有更改相符。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rm-inner-div

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a nice refactoring that simplifies the DOM structure of the Checkbox component by removing an unnecessary inner <span>. The corresponding CSS changes are also well-executed, moving styles from the inner element to the main component wrapper. I've added a couple of suggestions to the stylesheet to further improve the code by using a CSS shorthand for brevity and to fix a minor pre-existing animation bug that became apparent during the refactor.

Comment on lines +13 to +15
border-color: #d9d9d9;
border-style: solid;
border-width: 1px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For conciseness and better readability, consider using the border shorthand property to set the width, style, and color of the border in one declaration.

  border: 1px solid #d9d9d9;

Comment on lines 58 to 69
.@{checkboxPrefixCls}-checked {
background-color: #3dbcf6;
border-color: #3dbcf6;

&:hover {
.@{checkboxInnerPrefixCls} {
border-color: #3dbcf6;
}
}

.@{checkboxInnerPrefixCls} {
border-color: #3dbcf6;
background-color: #3dbcf6;

&:after {
transform: rotate(45deg);
position: absolute;
left: 4px;
top: 1px;
display: table;
width: 5px;
height: 8px;
border: 2px solid #ffffff;
border-top: 0;
border-left: 0;
content: ' ';
animation-timing-function: cubic-bezier(0.68, -0.55, 0.27, 1.55);
animation-duration: 0.3s;
animation-name: amCheckboxOut;
}
}

@media print {
box-shadow: inset 0 0 0 16px #3dbcf6;
}
@media print {
box-shadow: inset 0 0 0 16px #3dbcf6;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This refactoring correctly preserves the existing styles. However, I noticed a potential pre-existing issue with the checkmark animation that could be fixed here. The checkmark currently fades out after appearing because of animation-name: amCheckboxOut on the base :after element. To fix this, you can override the animation for the checked state to use amCheckboxIn and ensure the final state persists. This will make use of the currently unused amCheckboxIn keyframes and provide a better user experience.

.@{checkboxPrefixCls}-checked {
  background-color: #3dbcf6;
  border-color: #3dbcf6;

  &:after {
    animation-name: amCheckboxIn;
    animation-fill-mode: forwards;
  }

  &:hover {
    border-color: #3dbcf6;
  }

  @media print {
    box-shadow: inset 0 0 0 16px #3dbcf6;
  }
}

@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (66acc45) to head (06bd60a).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #297   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           30        30           
  Branches         5         5           
=========================================
  Hits            30        30           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@assets/index.less`:
- Around line 58-69: The checked state block for @{checkboxPrefixCls}-checked is
missing the &:after rule to apply the amCheckboxIn animation (the default :after
uses amCheckboxOut), so add an &:after nested rule inside
@{checkboxPrefixCls}-checked that sets animation-name: amCheckboxIn (and
matching animation-duration/animation-timing if used elsewhere) so the check
mark plays the "in" animation when checked; update the &:after selector that
references the pseudo-element and ensure it mirrors the properties used by the
default :after except with animation-name changed to amCheckboxIn.
- Around line 22-25: The current selector `&-input:focus + &` assumes the input
is a sibling of `.rc-checkbox` but the DOM in `src/index.tsx` places the input
inside `.rc-checkbox`, so the focus border style never matches; update the LESS
to target the parent when its child input is focused (e.g. replace the sibling
selector reference of `&-input:focus + &` with a parent selector that matches
`.rc-checkbox` containing the focused input, such as using
`:has(.rc-checkbox-input:focus)` on `.rc-checkbox`, or alternatively move the
focus style to the input and cascade it to the parent via a class toggle),
ensuring you reference the existing class names `&-input` / `.rc-checkbox` used
in the component.
🧹 Nitpick comments (1)
assets/index.less (1)

102-122: 动画关键帧定义正确,但存在厂商前缀不一致的小问题。

第 37 行使用了 -webkit-transform 前缀,但动画关键帧中只使用了标准 transform。对于现代浏览器这不是问题,但如果需要支持较旧的 WebKit 浏览器,建议保持一致性。

Comment on lines +22 to 25
&:hover,
&-input:focus + & {
border-color: #3dbcf6;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

find . -name "*.tsx" -o -name "*.jsx" -o -name "*.ts" -o -name "*.js" | grep -E "(index|checkbox)" | head -20

Repository: react-component/checkbox

Length of output: 106


🏁 Script executed:

# Look for the checkbox component structure
rg -n "className.*rc-checkbox" --type tsx --type jsx -A 5 -B 5

Repository: react-component/checkbox

Length of output: 95


🏁 Script executed:

# Search for input element and checkbox wrapper relationship
rg -n "rc-checkbox-input" --type tsx --type jsx -A 3 -B 3

Repository: react-component/checkbox

Length of output: 95


🏁 Script executed:

cat -n ./src/index.tsx | head -100

Repository: react-component/checkbox

Length of output: 3239


🏁 Script executed:

# Search for the input and checkbox element relationship
rg -n "rc-checkbox-input\|rc-checkbox" -A 5 -B 5

Repository: react-component/checkbox

Length of output: 50


🏁 Script executed:

cat -n ./src/index.tsx | tail -20

Repository: react-component/checkbox

Length of output: 611


🏁 Script executed:

# Check if there's more content after line 100
wc -l ./src/index.tsx

Repository: react-component/checkbox

Length of output: 87


🏁 Script executed:

sed -n '90,110p' ./src/index.tsx

Repository: react-component/checkbox

Length of output: 423


🏁 Script executed:

sed -n '1,50p' ./assets/index.less

Repository: react-component/checkbox

Length of output: 1152


修复 focus 选择器与 DOM 结构的不兼容问题。

选择器 &-input:focus + & 编译后为 .rc-checkbox-input:focus + .rc-checkbox,这是一个相邻兄弟选择器。然而,根据 src/index.tsx 的 DOM 结构,input 元素是 .rc-checkbox 的子元素而非兄弟元素,因此该选择器永远无法匹配。这导致 input 获得焦点时的边框颜色变化样式不会生效。

需要将选择器改为适配当前 DOM 结构的方案,例如使用 :has() 伪类或重构 DOM 关系。

🤖 Prompt for AI Agents
In `@assets/index.less` around lines 22 - 25, The current selector `&-input:focus
+ &` assumes the input is a sibling of `.rc-checkbox` but the DOM in
`src/index.tsx` places the input inside `.rc-checkbox`, so the focus border
style never matches; update the LESS to target the parent when its child input
is focused (e.g. replace the sibling selector reference of `&-input:focus + &`
with a parent selector that matches `.rc-checkbox` containing the focused input,
such as using `:has(.rc-checkbox-input:focus)` on `.rc-checkbox`, or
alternatively move the focus style to the input and cascade it to the parent via
a class toggle), ensuring you reference the existing class names `&-input` /
`.rc-checkbox` used in the component.

Comment on lines 58 to 69
.@{checkboxPrefixCls}-checked {
background-color: #3dbcf6;
border-color: #3dbcf6;

&:hover {
.@{checkboxInnerPrefixCls} {
border-color: #3dbcf6;
}
}

.@{checkboxInnerPrefixCls} {
border-color: #3dbcf6;
background-color: #3dbcf6;

&:after {
transform: rotate(45deg);
position: absolute;
left: 4px;
top: 1px;
display: table;
width: 5px;
height: 8px;
border: 2px solid #ffffff;
border-top: 0;
border-left: 0;
content: ' ';
animation-timing-function: cubic-bezier(0.68, -0.55, 0.27, 1.55);
animation-duration: 0.3s;
animation-name: amCheckboxOut;
}
}

@media print {
box-shadow: inset 0 0 0 16px #3dbcf6;
}
@media print {
box-shadow: inset 0 0 0 16px #3dbcf6;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

选中状态缺少 amCheckboxIn 动画。

默认的 :after 伪元素设置了 animation-name: amCheckboxOut,但选中状态没有添加 &:after 规则来应用 amCheckboxIn 动画。这会导致勾选标记在选中时无法正确显示动画效果。

🐛 建议添加选中状态的动画规则
 .@{checkboxPrefixCls}-checked {
   background-color: `#3dbcf6`;
   border-color: `#3dbcf6`;

+  &:after {
+    animation-name: amCheckboxIn;
+  }
+
   &:hover {
     border-color: `#3dbcf6`;
   }

   `@media` print {
     box-shadow: inset 0 0 0 16px `#3dbcf6`;
   }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.@{checkboxPrefixCls}-checked {
background-color: #3dbcf6;
border-color: #3dbcf6;
&:hover {
.@{checkboxInnerPrefixCls} {
border-color: #3dbcf6;
}
}
.@{checkboxInnerPrefixCls} {
border-color: #3dbcf6;
background-color: #3dbcf6;
&:after {
transform: rotate(45deg);
position: absolute;
left: 4px;
top: 1px;
display: table;
width: 5px;
height: 8px;
border: 2px solid #ffffff;
border-top: 0;
border-left: 0;
content: ' ';
animation-timing-function: cubic-bezier(0.68, -0.55, 0.27, 1.55);
animation-duration: 0.3s;
animation-name: amCheckboxOut;
}
}
@media print {
box-shadow: inset 0 0 0 16px #3dbcf6;
}
@media print {
box-shadow: inset 0 0 0 16px #3dbcf6;
}
}
.@{checkboxPrefixCls}-checked {
background-color: `#3dbcf6`;
border-color: `#3dbcf6`;
&:after {
animation-name: amCheckboxIn;
}
&:hover {
border-color: `#3dbcf6`;
}
`@media` print {
box-shadow: inset 0 0 0 16px `#3dbcf6`;
}
}
🤖 Prompt for AI Agents
In `@assets/index.less` around lines 58 - 69, The checked state block for
@{checkboxPrefixCls}-checked is missing the &:after rule to apply the
amCheckboxIn animation (the default :after uses amCheckboxOut), so add an
&:after nested rule inside @{checkboxPrefixCls}-checked that sets
animation-name: amCheckboxIn (and matching animation-duration/animation-timing
if used elsewhere) so the check mark plays the "in" animation when checked;
update the &:after selector that references the pseudo-element and ensure it
mirrors the properties used by the default :after except with animation-name
changed to amCheckboxIn.

@zombieJ zombieJ merged commit b3ea148 into master Jan 29, 2026
8 checks passed
@zombieJ zombieJ deleted the rm-inner-div branch January 29, 2026 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants